package com.xxx.video.main.adapters;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.xxx.video.main.fragments.VideoDetailsCommentFragment;
import com.xxx.video.main.fragments.VideoDetailsFragment;

public class VideoDetailsPagerAdapter extends FragmentStateAdapter {
    /**
     * video id
     */
    private String videoId;

    public VideoDetailsPagerAdapter(@NonNull FragmentActivity fragmentActivity, String videoId) {
        super(fragmentActivity);
        this.videoId = videoId;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        Bundle bundle = new Bundle();
        bundle.putString("Id", videoId);
        switch (position) {
            case 0:
                return VideoDetailsFragment.newInstance(bundle);
            case 1:
            default:
                return VideoDetailsCommentFragment.newInstance(bundle);
        }
    }

    @Override
    public int getItemCount() {
        return 2;
    }
}
